Introduction
Over the course of '96 and '97 I wrote two identical programs. One was
written in Borland Turbo Pascal 7, whilst the other was written in
x86 assembly language and compiled with A86. As far as possible, the
programs were written to the same specifications. The reason for doing
this was to look at the true differences between these two languages and
to assess the code overhead created by using a high level language (HLL).
The Program
The program, named Space, is a small disk utility planned for
public domain release (should anyone want it). It gives values for the bytes used/free (with percentages),
gives a disk capacity value (in Mb with 2 decimal places for < 10Mb) and
gives a small bar graph to show usage.* It supports command line parameters,
which dictate which disk the information is given for, and toggle the
values and bar graph. Additionally, a help screen is triggered by any of
the following command line parameters "-h /h -? /?". An incorrect command
line parameter results in a failure to execute with a return message
stating the incorrect parameter. It must also be able to deal with double
(or more) spaces between command line parameters. The programs should not
need extended registers such as EAX, so should run on a 286.
* free bar length = 20 squares [ascii code b0] * [used/total]
The Testing
*[Filez.com search for "Timer" revealed one such program, Timer100.zip on garbo]
The Results
A large difference was noticed between the first execution and subsequent
runs. Thus the program was run directly after a warm boot. Times were also
measured for an additional execution directly after this, which were
substantially quicker.
Speed:
286-14 Dan PC with 1Mb memory and 84Mb IDE Seagate Hard Disk
i) Control run
Conclusions
The choice of program was perhaps not ideal. Anything involving this form of
disk access will be slow- the second access being anything from 4-7 times
faster. When this difference alone is 2-3 seconds, who really cares about
differences of 0.055 seconds? Perhaps the Seagate disk, an IDE, was not that
fast. However, a faster disk drive is likely to be put in a computer with a
faster processor and then the processing differences are going to be even
less. There can be no decisive conclusions but the x86 version seems to have
few advatages......
.....But yet, I still write in x86 assembly language. Perhaps it is the
enjoyment of writing in a "difficult" language? Perhaps it is the enjoyment
of knowing what every bit, every byte is doing, all of the time? Perhaps it
is the strange satisfaction from knowing that no matter who wrote it, in
whatever high level language, with the hardware in my computer, it would be
difficult to get it smaller AND faster. Okay, I could make it faster or
smaller, but after a while they start being inversely proportional.
..... Conclusions... who needs them.........?
Hits on the homepage
To test the programs, I created a second program which simply triggered
int 1a,ax=0000h and outputed the low word tick count (suitably converted
to ascii). The tick was left at 18.206 per second. A batch file was then
written which ran the timer program, ran the program to be tested, and then
ran the timer program again. The time between values gave the time used
to execute the program plus any overhead the timer programs had. This was
assesed by running the batch file without a sample program and noting the
difference in time. Although there are programs available which measure
the time needed for program execution*, the one found did not handle
program command line parameters very well and the x86 version did not run
under it due to this. Although this shows a programming difference, it was
felt not to be significant enough to mean a rewrite of Space86.
The Pascal version was dramatically quicker to write, and the source code
was much shorter. However, a good amount of the time taken on the x86 version
was used to learn the language better. Additionally, debugging and testing
the x86 version took longer. As mentioned above, the x86 version
showed some problems when running as a child process due to parameter handling
problems but these occur at no other time.
Space [pascal]: EXE file 7,760 bytes
Space [x86]: COM file 1,528 bytes
ii) Hard Disk
iii) Floppy Disk
Tick count is left at 18.206 per second
First Run Second Run
Ticks Ticks
i) Control run 1 1
ii) Space [pascal]: 45 6
Space [x86]: 43 4
iii) Space [pascal]: 81 22
Space [x86]: 80 21
As can be seen from the above data, the x86 version was minimally faster,
in the region of one to two ticks [55 to 110 milliseconds]. On a
processor faster than the 286-14, it is likely that this difference would
be even smaller. The difference in size, however, is appreciable. However,
in the days where a Gig hard disk is becoming a bare minimum for a new
system, the extra 6290 bytes seems insignificant considering the extra time
required for the programming. In a larger program, this gain will be significant,
but the amount of time needed to create such a program without major procedure
libraries would often be prohibitive.
Please note that this was only meant to be a semi-serious test,
and should not be taken that seriously. For a copy of the source code, together with programs themselves, click here
If you wish to comment on this experiment, please
E-mail me (no flames please).
(c) 1997 B.T.Bromilow B.Med.Sci [[email protected]]